package com.alisls.demo.springcloud.service.user.entity.resource;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.persistence.*;

/**
 * 资源抽象类
 * 资源包含：1-菜单资源；2-控件资源；3-API资源
 *
 * 注解 @Inheritance设置继承策略
 *
 * @author Ke Wang
 * @date 2020/11/5
 */
@Entity
@Table(indexes = {@Index(name = "uk_code", columnList = "code", unique = true),
    @Index(name = "idx_name", columnList = "name", unique = false)
})
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Getter
@Setter
@ToString
public abstract class Resource {

    /**
     * 资源标识
     */
    @Id
    private Long id;

    /**
     * 资源编码
     */
    @Column(nullable = false, unique = true, length = 10)
    private String code;

    /**
     * 父级编码
     */
    @Column(nullable = false, length = 10)
    private String parentCode;

    /**
     * 资源名称
     */
    @Column(nullable = false, length = 100)
    private String name;

}
